package fw.helpers;

import java.util.Random;

import fw.ApplicationManager;

public class RandomizeHelper {

	public RandomizeHelper(ApplicationManager app) {
		this.app = app;
	}

	private final ApplicationManager app;
	private final static String[] symbolsList = { "~", "!", "@|", "#", "$", "%", "^", "&", "*", "(", ")", "_", "{",
			"}", "[", "]", "'", "\"", "|", "\\", "?", ".", ",", ":", ";", " " };
	private final static String[] lettersList = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
			"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I",
			"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };

	public final static String[] monthList = { "January", "February", "March", "April", "May", "June", "July",
			"August", "September", "October", "November", "December" };

	public final static String[] booleanList = { "true", "false" };

	/**
	 * Get random integer
	 * 
	 * @param p_minValue
	 * @param p_maxValue
	 * @return
	 */
	public Integer getRandomInt(int p_minValue, int p_maxValue) {
		Random random = new Random();
		int r_randomNumber = 0;

		r_randomNumber = random.nextInt((p_maxValue + 1) - p_minValue) + (p_minValue);

		return r_randomNumber;
	}

	/**
	 * Get random string
	 * 
	 * @return
	 */
	public String getRandomDigits(Integer digitLenght) {
		StringBuffer result = new StringBuffer(digitLenght);

		for (int i = 0; i < digitLenght; i++) {
			result.append(getRandomInt(0, 9).toString());
		}

		return result.toString();
	}

	/**
	 * Get random string
	 * 
	 * @return
	 */
	public String getRandomString(Integer stringLenght) {
		StringBuffer result = new StringBuffer(stringLenght);

		for (int i = 0; i < stringLenght; i++) {
			result.append(getRandomLetter());
		}

		return result.toString();
	}

	/**
	 * Get random symbol
	 * 
	 * @return String
	 */
	public String getRandomSymbol() {
		return getRandomValueFromList(symbolsList);
	}

	/**
	 * Get random letter
	 * 
	 * @return String
	 */
	public String getRandomLetter() {
		return getRandomValueFromList(lettersList);
	}

	/**
	 * Get random letter
	 * 
	 * @return String
	 */
	public String getRandomMonth() {
		return getRandomValueFromList(monthList);
	}

	/**
	 * Get random boolean
	 * 
	 * @return String
	 */
	public String getRandomBoolean() {
		return getRandomValueFromList(booleanList);
	}

	public String getRandomValueFromList(String[] list) {
		int index = getRandomInt(0, list.length - 1);

		return list[index];
	}

	public String getRandomEmptyData(String text) {
		if (getRandomInt(0, 3) == 0) {
			text = "";
		}
		return text;
	}
}